<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改维保项目合同')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-contact-edit" th:object="${mtContact}">
            <input name="mtContractId" th:field="*{mtContractId}" type="hidden" id="mtContractId">
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">合同名称：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="mtContractName" th:field="*{mtContractName}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group" >-->
<!--                <label class="col-sm-3 control-label">维保合同上传：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input id="mtContractUpload" name="file" th:field="*{mtContractUpload}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">维保费用金额：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="mtPrice" th:field="*{mtPrice}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">付款方式：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="mtPayMethod" th:field="*{mtPayMethod}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">维保合同起始日期：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group date">-->
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
<!--                        <input name="mtContractDate" th:value="${#dates.format(mtContact.mtContractDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">维保费发票是/否开具：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="radio-box">-->
<!--                        <input type="radio" name="mtInvoiceStatus" value="1" checked>-->
<!--                        <label th:for="mtInvoiceStatus" th:text="是"></label>-->
<!--                    </div>-->
<!--                    <div class="radio-box">-->
<!--                        <input type="radio" name="mtInvoiceStatus" value="0">-->
<!--                        <label th:for="mtInvoiceStatus" th:text="否"></label>-->
<!--                    </div>-->
<!--                    &lt;!&ndash;                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>&ndash;&gt;-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group" >
                <label class="col-sm-3 control-label">维保费发票是/否送至甲方并签收：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" name="mtInvoiceSignfor" value="1" checked>
                        <label th:for="mtInvoiceStatus" th:text="是"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" name="mtInvoiceSignfor" value="0">
                        <label th:for="mtInvoiceStatus" th:text="否"></label>
                    </div>
                </div>
            </div>
            <div class="form-group" >
                <label class="col-sm-3 control-label">维保费发票上传：</label>
                <div class="col-sm-8">
<!--                    <input name="mtInvoiceUpload"  th:field="*{mtInvoiceUpload}" th:unless="${mtContact.mtInvoiceUpload!=null}" class="form-control" type="text" >-->
                    <input id="mtInvoiceUpload" name="file1"  th:field="*{mtInvoiceUpload}" class="form-control" type="file" >
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">伪外键：</label>
                <div class="col-sm-8">
                    <input name="mtId" th:field="*{mtId}" class="form-control" type="text" id="mtId">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "ruoyi/contact";

        $("#form-contact-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                uploadFile();
                //$.operate.save(prefix + "/editone", $('#form-contact-edit').serialize());
            }
        }

            function uploadFile() {
                var formData = new FormData();
                // formData.append('mtContractName', $("#mtContractName").val());
                // formData.append('mtPrice', $("#mtPrice").val());
                // formData.append('mtPayMethod', $("#mtPayMethod").val());
                // formData.append('mtContractDate', $("#mtContractDate").val());
                // formData.append('mtInvoiceStatus', $("input[name='mtInvoiceStatus']:checked").val());
                formData.append('mtInvoiceSignfor', $("input[name='mtInvoiceSignfor']:checked").val());
                // formData.append('file', $('#mtContractUpload').val());
                formData.append('file1', $('#mtInvoiceUpload')[0].files[0]);
                formData.append('mtId', $("#mtId").val());
                formData.append('mtContractId', $("#mtContractId").val());
                $.ajax({
                    url: prefix + "/edit",
                    type: 'post',
                    cache: false,
                    data: formData,
                    processData: false,
                    contentType: false,
                    dataType: "json",
                    success: function (result) {
                        $.operate.successCallback(result);
                    }
                });
            }
        $("input[name='mtContractDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>